package edu.xidian.sei.mlcs

import java.io.File
import java.io.PrintWriter

import scala.io.Source

import edu.xidian.sei.mlcs.util.JsonUtil

class SubGraphMap {
  def nodeFileReader(location: Location): InNode = {
    val file = Source.fromFile(location.toFileIndex + ".txt")
    val json = file.getLines().next()
    val obj = JsonUtil.fromJson[InNode](json)
    obj
  }

  def nodeFileWriter(node: InNode) {
    val json = JsonUtil.toJson(node)
    val writer = new PrintWriter(new File(node.loc.toFileIndex + ".txt"))
    writer.println(json)
    writer.close()
  }
}